package com.yinggu.service;

import com.yinggu.dao.UserDao;
import com.yinggu.pojo.KUser;
import com.yinggu.utils.DBUtil;
import com.yinggu.utils.Page;

import java.sql.SQLException;
import java.util.List;

public class UserService {
    UserDao userDao = new UserDao();
    public KUser login(String userName,String pwd) {
        try {
            return userDao.login(userName,pwd);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }
    public List<KUser> getUsers(String key, Page page) {
        try {
            return userDao.getUsers(key, page);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }
    public int getCount(String key) {
        try {
            return userDao.getCount(key);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return 0;
    }
    public boolean addUser(KUser user) {
        return userDao.addUser(user) > 0;
    }
    public boolean editUser(KUser user) {
        return userDao.editUser(user) > 0;
    }
    public boolean removeUser(int id) {
        return userDao.removeUser(id) > 0;
    }
    public KUser getUser(int id) {
        try {
            return userDao.getUser(id);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return null;
    }
}
